import codecs
import re
def parse_config(config_path):
    rules = {}
    key = ""
    with codecs.open(config_path, "r") as f:
        f.readline()
        for line in f.readlines():
            if "[" in line and "]" in line:
                key = line.strip().split("[")[1].split("]")[0]
                rules[key] = {}
            else:
                line = line.strip()
                line = re.sub(r'\s+', ' ', line)
                line = line.split(" ")
                rules[key][line[0]] = int(line[1])
    return rules